package com.hadwinling.lotdb.config;

import org.apache.iotdb.rpc.IoTDBConnectionException;
import org.apache.iotdb.session.Session;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @description:
 * @author: hadwinling
 * @time: 2021/2/5 下午9:18
 */
@Configuration
public class LOTDBConfig {
    @Value("${spring.lotdb.hort}")
    private String hort;
    @Value("${spring.lotdb.port}")
    private int port;
    @Value("${spring.lotdb.username}")
    private String username;
    @Value("${spring.lotdb.password}")
    private String password;

    @Bean
    public Session lotdbSession() {
        Session session = new Session(hort, port, username, password);
        try {
            session.open(false);
        } catch (IoTDBConnectionException e) {
            e.printStackTrace();
        }
        return session;
    }


}
